package com.company.utils;

public class BinarySearch {
    public static void main(String[] args) {
        int []  ints= {12,20,33,34,39,111,23213};
        System.out.println(search(ints,20));
    }
    public static  int search(int[] list,int value){
        int low = 0;
        int high = list.length-1;
        while(low<=high){
            int mid = (low+high)/2;
            if(list[mid] == value ) return mid;
            else if(list[mid] > value){
                high = mid-1;
            }
            else{
                low = mid+1;
            }
        }
        return -1;
    }
}
